<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title></title>
	</head>
	<body></body>
	<script src="js/jquery-3.0.0.min.js" type="text/javascript" charset="utf-8"></script>
	 <script src="js/jquery.min.js?v=2.1.4"></script>
<script src="boss/js/core.js"></script>

	<script type="text/javascript">
		$(function(){
			  var  code=getvl("code");
	if(code!=""){
		$.ajax({
			url: urlcore + "/api/user/getOpenid?code="+code,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					 if(data.data.userType==3 && data.data.adminType==2){
					 	 toLogin(data.data.phone,data.data.password);
					   }else{
                          window.location.href="quanxian.html";					   	  
					   }
				} else {
				 //alert("未绑定微信登录后自动绑定");
                 window.location.href="wx_login.html";
				}
			},
			error: function() {
				alert("error");
			}
		});
			  }
		});
		
		
		
		function toLogin(phone,password){
	if(phone!="" && password!=""){
		    $.ajax({
        url:  urlcore + "/api/login/loginPhoneweixinadmin",
        type: "post",
        contentType: "application/json;charset=utf-8",
        data: JSON.stringify({
            "phone":phone,
            "password":password
        }),
        dataType: "json",
        success:function(data){
            if (data.success == true) {
					//设置cookie
					var domain_url = urlcore.split('://')[1];
					if (domain_url.indexOf(':') > -1) {
						domain_url = domain_url.split(':')[0];
					}else{
						domain_url = domain_url.split('/')[0];
					}
					document.cookie = "JSESSIONID="+data.data.token+";path=/;domain="+domain_url;
					window.location.href="wx_index.html";
			
             }else{
             	 // alert(data.msg);
             	window.location.href="quanxian.html";
            }
        },
        error: function() {
            alert("error");
        }
    });
	}
}

	</script>
</html>